type CountryCode = {
  code: string;
  'country-code': string;
  name: string;
};

const countryCodes: CountryCode[] = [
  // prioritize the US, since majority of customers are from there
  {name: 'United States', code: 'US', 'country-code': '840'},

  {name: 'Afghanistan', code: 'AF', 'country-code': '004'},
  {name: 'Åland Islands', code: 'AX', 'country-code': '248'},
  {name: 'Albania', code: 'AL', 'country-code': '008'},
  {name: 'Algeria', code: 'DZ', 'country-code': '012'},
  {name: 'American Samoa', code: 'AS', 'country-code': '016'},
  {name: 'Andorra', code: 'AD', 'country-code': '020'},
  {name: 'Angola', code: 'AO', 'country-code': '024'},
  {name: 'Anguilla', code: 'AI', 'country-code': '660'},
  {name: 'Antarctica', code: 'AQ', 'country-code': '010'},
  {name: 'Antigua and Barbuda', code: 'AG', 'country-code': '028'},
  {name: 'Argentina', code: 'AR', 'country-code': '032'},
  {name: 'Armenia', code: 'AM', 'country-code': '051'},
  {name: 'Aruba', code: 'AW', 'country-code': '533'},
  {name: 'Australia', code: 'AU', 'country-code': '036'},
  {name: 'Austria', code: 'AT', 'country-code': '040'},
  {name: 'Azerbaijan', code: 'AZ', 'country-code': '031'},
  {name: 'Bahamas', code: 'BS', 'country-code': '044'},
  {name: 'Bahrain', code: 'BH', 'country-code': '048'},
  {name: 'Bangladesh', code: 'BD', 'country-code': '050'},
  {name: 'Barbados', code: 'BB', 'country-code': '052'},
  {name: 'Belarus', code: 'BY', 'country-code': '112'},
  {name: 'Belgium', code: 'BE', 'country-code': '056'},
  {name: 'Belize', code: 'BZ', 'country-code': '084'},
  {name: 'Benin', code: 'BJ', 'country-code': '204'},
  {name: 'Bermuda', code: 'BM', 'country-code': '060'},
  {name: 'Bhutan', code: 'BT', 'country-code': '064'},
  {name: 'Bolivia (Plurinational State of)', code: 'BO', 'country-code': '068'},
  {name: 'Bonaire, Sint Eustatius and Saba', code: 'BQ', 'country-code': '535'},
  {name: 'Bosnia and Herzegovina', code: 'BA', 'country-code': '070'},
  {name: 'Botswana', code: 'BW', 'country-code': '072'},
  {name: 'Bouvet Island', code: 'BV', 'country-code': '074'},
  {name: 'Brazil', code: 'BR', 'country-code': '076'},
  {name: 'British Indian Ocean Territory', code: 'IO', 'country-code': '086'},
  {name: 'Brunei Darussalam', code: 'BN', 'country-code': '096'},
  {name: 'Bulgaria', code: 'BG', 'country-code': '100'},
  {name: 'Burkina Faso', code: 'BF', 'country-code': '854'},
  {name: 'Burundi', code: 'BI', 'country-code': '108'},
  {name: 'Cambodia', code: 'KH', 'country-code': '116'},
  {name: 'Cameroon', code: 'CM', 'country-code': '120'},
  {name: 'Canada', code: 'CA', 'country-code': '124'},
  {name: 'Cabo Verde', code: 'CV', 'country-code': '132'},
  {name: 'Cayman Islands', code: 'KY', 'country-code': '136'},
  {name: 'Central African Republic', code: 'CF', 'country-code': '140'},
  {name: 'Chad', code: 'TD', 'country-code': '148'},
  {name: 'Chile', code: 'CL', 'country-code': '152'},
  {name: 'China', code: 'CN', 'country-code': '156'},
  {name: 'Christmas Island', code: 'CX', 'country-code': '162'},
  {name: 'Cocos (Keeling) Islands', code: 'CC', 'country-code': '166'},
  {name: 'Colombia', code: 'CO', 'country-code': '170'},
  {name: 'Comoros', code: 'KM', 'country-code': '174'},
  {name: 'Congo', code: 'CG', 'country-code': '178'},
  {name: 'Congo (Democratic Republic of the)', code: 'CD', 'country-code': '180'},
  {name: 'Cook Islands', code: 'CK', 'country-code': '184'},
  {name: 'Costa Rica', code: 'CR', 'country-code': '188'},
  {name: "Côte d'Ivoire", code: 'CI', 'country-code': '384'},
  {name: 'Croatia', code: 'HR', 'country-code': '191'},
  {name: 'Cuba', code: 'CU', 'country-code': '192'},
  {name: 'Curaçao', code: 'CW', 'country-code': '531'},
  {name: 'Cyprus', code: 'CY', 'country-code': '196'},
  {name: 'Czech Republic', code: 'CZ', 'country-code': '203'},
  {name: 'Denmark', code: 'DK', 'country-code': '208'},
  {name: 'Djibouti', code: 'DJ', 'country-code': '262'},
  {name: 'Dominica', code: 'DM', 'country-code': '212'},
  {name: 'Dominican Republic', code: 'DO', 'country-code': '214'},
  {name: 'Ecuador', code: 'EC', 'country-code': '218'},
  {name: 'Egypt', code: 'EG', 'country-code': '818'},
  {name: 'El Salvador', code: 'SV', 'country-code': '222'},
  {name: 'Equatorial Guinea', code: 'GQ', 'country-code': '226'},
  {name: 'Eritrea', code: 'ER', 'country-code': '232'},
  {name: 'Estonia', code: 'EE', 'country-code': '233'},
  {name: 'Ethiopia', code: 'ET', 'country-code': '231'},
  {name: 'Falkland Islands (Malvinas)', code: 'FK', 'country-code': '238'},
  {name: 'Faroe Islands', code: 'FO', 'country-code': '234'},
  {name: 'Fiji', code: 'FJ', 'country-code': '242'},
  {name: 'Finland', code: 'FI', 'country-code': '246'},
  {name: 'France', code: 'FR', 'country-code': '250'},
  {name: 'French Guiana', code: 'GF', 'country-code': '254'},
  {name: 'French Polynesia', code: 'PF', 'country-code': '258'},
  {name: 'French Southern Territories', code: 'TF', 'country-code': '260'},
  {name: 'Gabon', code: 'GA', 'country-code': '266'},
  {name: 'Gambia', code: 'GM', 'country-code': '270'},
  {name: 'Georgia', code: 'GE', 'country-code': '268'},
  {name: 'Germany', code: 'DE', 'country-code': '276'},
  {name: 'Ghana', code: 'GH', 'country-code': '288'},
  {name: 'Gibraltar', code: 'GI', 'country-code': '292'},
  {name: 'Greece', code: 'GR', 'country-code': '300'},
  {name: 'Greenland', code: 'GL', 'country-code': '304'},
  {name: 'Grenada', code: 'GD', 'country-code': '308'},
  {name: 'Guadeloupe', code: 'GP', 'country-code': '312'},
  {name: 'Guam', code: 'GU', 'country-code': '316'},
  {name: 'Guatemala', code: 'GT', 'country-code': '320'},
  {name: 'Guernsey', code: 'GG', 'country-code': '831'},
  {name: 'Guinea', code: 'GN', 'country-code': '324'},
  {name: 'Guinea-Bissau', code: 'GW', 'country-code': '624'},
  {name: 'Guyana', code: 'GY', 'country-code': '328'},
  {name: 'Haiti', code: 'HT', 'country-code': '332'},
  {name: 'Heard Island and McDonald Islands', code: 'HM', 'country-code': '334'},
  {name: 'Holy See', code: 'VA', 'country-code': '336'},
  {name: 'Honduras', code: 'HN', 'country-code': '340'},
  {name: 'Hong Kong', code: 'HK', 'country-code': '344'},
  {name: 'Hungary', code: 'HU', 'country-code': '348'},
  {name: 'Iceland', code: 'IS', 'country-code': '352'},
  {name: 'India', code: 'IN', 'country-code': '356'},
  {name: 'Indonesia', code: 'ID', 'country-code': '360'},
  {name: 'Iran (Islamic Republic of)', code: 'IR', 'country-code': '364'},
  {name: 'Iraq', code: 'IQ', 'country-code': '368'},
  {name: 'Ireland', code: 'IE', 'country-code': '372'},
  {name: 'Isle of Man', code: 'IM', 'country-code': '833'},
  {name: 'Israel', code: 'IL', 'country-code': '376'},
  {name: 'Italy', code: 'IT', 'country-code': '380'},
  {name: 'Jamaica', code: 'JM', 'country-code': '388'},
  {name: 'Japan', code: 'JP', 'country-code': '392'},
  {name: 'Jersey', code: 'JE', 'country-code': '832'},
  {name: 'Jordan', code: 'JO', 'country-code': '400'},
  {name: 'Kazakhstan', code: 'KZ', 'country-code': '398'},
  {name: 'Kenya', code: 'KE', 'country-code': '404'},
  {name: 'Kiribati', code: 'KI', 'country-code': '296'},
  {name: "Korea (Democratic People's Republic of)", code: 'KP', 'country-code': '408'},
  {name: 'Korea (Republic of)', code: 'KR', 'country-code': '410'},
  {name: 'Kuwait', code: 'KW', 'country-code': '414'},
  {name: 'Kyrgyzstan', code: 'KG', 'country-code': '417'},
  {name: "Lao People's Democratic Republic", code: 'LA', 'country-code': '418'},
  {name: 'Latvia', code: 'LV', 'country-code': '428'},
  {name: 'Lebanon', code: 'LB', 'country-code': '422'},
  {name: 'Lesotho', code: 'LS', 'country-code': '426'},
  {name: 'Liberia', code: 'LR', 'country-code': '430'},
  {name: 'Libya', code: 'LY', 'country-code': '434'},
  {name: 'Liechtenstein', code: 'LI', 'country-code': '438'},
  {name: 'Lithuania', code: 'LT', 'country-code': '440'},
  {name: 'Luxembourg', code: 'LU', 'country-code': '442'},
  {name: 'Macao', code: 'MO', 'country-code': '446'},
  {
    name: 'Macedonia (the former Yugoslav Republic of)',
    code: 'MK',
    'country-code': '807',
  },
  {name: 'Madagascar', code: 'MG', 'country-code': '450'},
  {name: 'Malawi', code: 'MW', 'country-code': '454'},
  {name: 'Malaysia', code: 'MY', 'country-code': '458'},
  {name: 'Maldives', code: 'MV', 'country-code': '462'},
  {name: 'Mali', code: 'ML', 'country-code': '466'},
  {name: 'Malta', code: 'MT', 'country-code': '470'},
  {name: 'Marshall Islands', code: 'MH', 'country-code': '584'},
  {name: 'Martinique', code: 'MQ', 'country-code': '474'},
  {name: 'Mauritania', code: 'MR', 'country-code': '478'},
  {name: 'Mauritius', code: 'MU', 'country-code': '480'},
  {name: 'Mayotte', code: 'YT', 'country-code': '175'},
  {name: 'Mexico', code: 'MX', 'country-code': '484'},
  {name: 'Micronesia (Federated States of)', code: 'FM', 'country-code': '583'},
  {name: 'Moldova (Republic of)', code: 'MD', 'country-code': '498'},
  {name: 'Monaco', code: 'MC', 'country-code': '492'},
  {name: 'Mongolia', code: 'MN', 'country-code': '496'},
  {name: 'Montenegro', code: 'ME', 'country-code': '499'},
  {name: 'Montserrat', code: 'MS', 'country-code': '500'},
  {name: 'Morocco', code: 'MA', 'country-code': '504'},
  {name: 'Mozambique', code: 'MZ', 'country-code': '508'},
  {name: 'Myanmar', code: 'MM', 'country-code': '104'},
  {name: 'Namibia', code: 'NA', 'country-code': '516'},
  {name: 'Nauru', code: 'NR', 'country-code': '520'},
  {name: 'Nepal', code: 'NP', 'country-code': '524'},
  {name: 'Netherlands', code: 'NL', 'country-code': '528'},
  {name: 'New Caledonia', code: 'NC', 'country-code': '540'},
  {name: 'New Zealand', code: 'NZ', 'country-code': '554'},
  {name: 'Nicaragua', code: 'NI', 'country-code': '558'},
  {name: 'Niger', code: 'NE', 'country-code': '562'},
  {name: 'Nigeria', code: 'NG', 'country-code': '566'},
  {name: 'Niue', code: 'NU', 'country-code': '570'},
  {name: 'Norfolk Island', code: 'NF', 'country-code': '574'},
  {name: 'Northern Mariana Islands', code: 'MP', 'country-code': '580'},
  {name: 'Norway', code: 'NO', 'country-code': '578'},
  {name: 'Oman', code: 'OM', 'country-code': '512'},
  {name: 'Pakistan', code: 'PK', 'country-code': '586'},
  {name: 'Palau', code: 'PW', 'country-code': '585'},
  {name: 'Palestine, State of', code: 'PS', 'country-code': '275'},
  {name: 'Panama', code: 'PA', 'country-code': '591'},
  {name: 'Papua New Guinea', code: 'PG', 'country-code': '598'},
  {name: 'Paraguay', code: 'PY', 'country-code': '600'},
  {name: 'Peru', code: 'PE', 'country-code': '604'},
  {name: 'Philippines', code: 'PH', 'country-code': '608'},
  {name: 'Pitcairn', code: 'PN', 'country-code': '612'},
  {name: 'Poland', code: 'PL', 'country-code': '616'},
  {name: 'Portugal', code: 'PT', 'country-code': '620'},
  {name: 'Puerto Rico', code: 'PR', 'country-code': '630'},
  {name: 'Qatar', code: 'QA', 'country-code': '634'},
  {name: 'Réunion', code: 'RE', 'country-code': '638'},
  {name: 'Romania', code: 'RO', 'country-code': '642'},
  {name: 'Russian Federation', code: 'RU', 'country-code': '643'},
  {name: 'Rwanda', code: 'RW', 'country-code': '646'},
  {name: 'Saint Barthélemy', code: 'BL', 'country-code': '652'},
  {
    name: 'Saint Helena, Ascension and Tristan da Cunha',
    code: 'SH',
    'country-code': '654',
  },
  {name: 'Saint Kitts and Nevis', code: 'KN', 'country-code': '659'},
  {name: 'Saint Lucia', code: 'LC', 'country-code': '662'},
  {name: 'Saint Martin (French part)', code: 'MF', 'country-code': '663'},
  {name: 'Saint Pierre and Miquelon', code: 'PM', 'country-code': '666'},
  {name: 'Saint Vincent and the Grenadines', code: 'VC', 'country-code': '670'},
  {name: 'Samoa', code: 'WS', 'country-code': '882'},
  {name: 'San Marino', code: 'SM', 'country-code': '674'},
  {name: 'Sao Tome and Principe', code: 'ST', 'country-code': '678'},
  {name: 'Saudi Arabia', code: 'SA', 'country-code': '682'},
  {name: 'Senegal', code: 'SN', 'country-code': '686'},
  {name: 'Serbia', code: 'RS', 'country-code': '688'},
  {name: 'Seychelles', code: 'SC', 'country-code': '690'},
  {name: 'Sierra Leone', code: 'SL', 'country-code': '694'},
  {name: 'Singapore', code: 'SG', 'country-code': '702'},
  {name: 'Sint Maarten (Dutch part)', code: 'SX', 'country-code': '534'},
  {name: 'Slovakia', code: 'SK', 'country-code': '703'},
  {name: 'Slovenia', code: 'SI', 'country-code': '705'},
  {name: 'Solomon Islands', code: 'SB', 'country-code': '090'},
  {name: 'Somalia', code: 'SO', 'country-code': '706'},
  {name: 'South Africa', code: 'ZA', 'country-code': '710'},
  {
    name: 'South Georgia and the South Sandwich Islands',
    code: 'GS',
    'country-code': '239',
  },
  {name: 'South Sudan', code: 'SS', 'country-code': '728'},
  {name: 'Spain', code: 'ES', 'country-code': '724'},
  {name: 'Sri Lanka', code: 'LK', 'country-code': '144'},
  {name: 'Sudan', code: 'SD', 'country-code': '729'},
  {name: 'Suriname', code: 'SR', 'country-code': '740'},
  {name: 'Svalbard and Jan Mayen', code: 'SJ', 'country-code': '744'},
  {name: 'Swaziland', code: 'SZ', 'country-code': '748'},
  {name: 'Sweden', code: 'SE', 'country-code': '752'},
  {name: 'Switzerland', code: 'CH', 'country-code': '756'},
  {name: 'Syrian Arab Republic', code: 'SY', 'country-code': '760'},
  {name: 'Taiwan', code: 'TW', 'country-code': '158'},
  {name: 'Tajikistan', code: 'TJ', 'country-code': '762'},
  {name: 'Tanzania, United Republic of', code: 'TZ', 'country-code': '834'},
  {name: 'Thailand', code: 'TH', 'country-code': '764'},
  {name: 'Timor-Leste', code: 'TL', 'country-code': '626'},
  {name: 'Togo', code: 'TG', 'country-code': '768'},
  {name: 'Tokelau', code: 'TK', 'country-code': '772'},
  {name: 'Tonga', code: 'TO', 'country-code': '776'},
  {name: 'Trinidad and Tobago', code: 'TT', 'country-code': '780'},
  {name: 'Tunisia', code: 'TN', 'country-code': '788'},
  {name: 'Turkey', code: 'TR', 'country-code': '792'},
  {name: 'Turkmenistan', code: 'TM', 'country-code': '795'},
  {name: 'Turks and Caicos Islands', code: 'TC', 'country-code': '796'},
  {name: 'Tuvalu', code: 'TV', 'country-code': '798'},
  {name: 'Uganda', code: 'UG', 'country-code': '800'},
  {name: 'Ukraine', code: 'UA', 'country-code': '804'},
  {name: 'United Arab Emirates', code: 'AE', 'country-code': '784'},
  {
    name: 'United Kingdom of Great Britain and Northern Ireland',
    code: 'GB',
    'country-code': '826',
  },
  {name: 'United States Minor Outlying Islands', code: 'UM', 'country-code': '581'},
  {name: 'Uruguay', code: 'UY', 'country-code': '858'},
  {name: 'Uzbekistan', code: 'UZ', 'country-code': '860'},
  {name: 'Vanuatu', code: 'VU', 'country-code': '548'},
  {name: 'Venezuela (Bolivarian Republic of)', code: 'VE', 'country-code': '862'},
  {name: 'Viet Nam', code: 'VN', 'country-code': '704'},
  {name: 'Virgin Islands (British)', code: 'VG', 'country-code': '092'},
  {name: 'Virgin Islands (U.S.)', code: 'VI', 'country-code': '850'},
  {name: 'Wallis and Futuna', code: 'WF', 'country-code': '876'},
  {name: 'Western Sahara', code: 'EH', 'country-code': '732'},
  {name: 'Yemen', code: 'YE', 'country-code': '887'},
  {name: 'Zambia', code: 'ZM', 'country-code': '894'},
  {name: 'Zimbabwe', code: 'ZW', 'country-code': '716'},
];

const getCountryByCode = (code?: string | null): CountryCode | undefined =>
  code ? countryCodes.find(c => c.code === code) : undefined;

export {countryCodes, getCountryByCode};
